<template>
  <div class="multi-domain-test">
    <h2>多领域属性测试</h2>
    <Button @click="loadData" :loading="loading"> 加载模拟数据 </Button>

    <div v-if="data" class="data-display">
      <h3>加载的数据:</h3>
      <pre>{{ JSON.stringify(data, null, 2) }}</pre>
    </div>

    <div v-if="error" class="error-display">
      <h3>错误信息:</h3>
      <pre>{{ error }}</pre>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import { Button } from 'ant-design-vue';
import { getMultiDomainProperties } from '../../../../api/resource-center/property-api';

const loading = ref(false);
const data = ref(null);
const error = ref('');

const loadData = async () => {
  loading.value = true;
  error.value = '';
  data.value = null;

  try {
    const response = await getMultiDomainProperties({ resourceId: '1' });
    console.log('API响应:', response);

    if (response.success && response.data) {
      data.value = response.data;
    } else {
      error.value = response.message || '加载失败';
    }
  } catch (err) {
    console.error('加载数据失败:', err);
    error.value = err instanceof Error ? err.message : '未知错误';
    errinstanceofErrorerr.messageerrinstanceofErrorerr.message;
  } finally {
    loading.value = false;
  }
};
</script>

<style scoped>
.multi-domain-test {
  padding: 20px;
}

.data-display,
.error-display {
  padding: 16px;
  margin-top: 20px;
  background: #fafafa;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
}

.data-display pre,
.error-display pre {
  max-height: 400px;
  overflow-y: auto;
  word-break: break-all;
  white-space: pre-wrap;
}

.error-display {
  background: #fff2f0;
  border-color: #ff4d4f;
}
</style>
